import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

public class Config {
    public HikariConfig config(){
        HikariConfig config = new HikariConfig();
        config.setDriverClassName("com.mysql.cj.jdbc.Driver");
        config.setJdbcUrl("jdbc:mysql://localhost:3306/studentplace?useSSL=false&serverTimezone=Hongkong&characterEncoding=utf-8&autoReconnect=true");
        config.setUsername("root");
        config.setPassword("1234");
        config.setMaximumPoolSize(5);
        config.setMinimumIdle(2);
        return config;
    }
    @Bean
    public HikariDataSource dataSource(){
        HikariDataSource ds = new HikariDataSource(config());
        return ds;
    }
}
